<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>用户管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$('#inputForm').bootstrapValidator({
				message: 'This value is not valid',
				feedbackIcons: {
					valid: 'glyphicon glyphicon-ok',
					invalid: 'glyphicon glyphicon-remove',
					validating: 'glyphicon glyphicon-refresh'
				},
				fields: {
					no: {
						message: '工号格式错误',
						validators: {
							notEmpty: {
								message: '工号不能为空'
							}
						}
					},
					name: {
						message: '姓名格式错误',
						validators: {
							notEmpty: {
								message: '姓名不能为空'
							}
						}
					},
					loginName: {
						message: '只能填入数字与字母',
						validators: {
							notEmpty: {
								message: '登陆名不能为空'
							},
							regexp: {
								regexp: /^[a-zA-Z0-9_\.#\$]+$/,
								message: '只能填入数字与字母_.#$'
							}
						}
					},
					email: {
						validators: {
							notEmpty: {
								message: '邮箱不能为空'
							},
							emailAddress: {
								message: '邮箱格式错误'
							}
						}
					},
					newPassword: {
						validators: {
							identical: {
								field: 'confirmNewPassword',
								message: '两次输入不一致'
							}
						}
					},
					confirmNewPassword: {
						validators: {
							identical: {
								field: 'newPassword',
								message: '两次输入不一致'
							}
						}
					}
				}
			})
		});
	</script>
</head>
<body>
	<ul class="nav nav-tabs nav-tabss">
		<li><a href="${ctx}/system/user/">用户列表</a></li>
		<li class="active"><a href="${ctx}/system/user/form?id=${user.id}">用户<shiro:hasPermission name="system:user:edit">${not empty user.id?'修改':'添加'}</shiro:hasPermission><shiro:lacksPermission name="system:user:edit">查看</shiro:lacksPermission></a></li>
	</ul>
	<div class="ibox-content">
		<form:form id="inputForm" modelAttribute="user" action="${ctx}/system/user/save" method="post"  class="form-horizontal">
			<tags:message content="${message}"/>
			<form:hidden path="id"/>
			<div class="form-group">
				<label class="col-sm-2 control-label">工号:</label>
				<div class="col-sm-4">
					<form:input path="no" htmlEscape="false" maxlength="50" class="required form-control"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="hr-line-dashed"></div>

			<div class="form-group">
				<label class="col-sm-2 control-label" for="name">姓名:</label>
				<div class="col-sm-4">
					<form:input path="name" htmlEscape="false"  maxlength="200" class="required form-control" />
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">登录名:</label>
				<div class="col-sm-4">
					<input id="oldLoginName" name="oldLoginName" type="hidden" value="${user.loginName}">
					<form:input path="loginName" htmlEscape="false" maxlength="50" class="required form-control"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">密码:</label>
				<div class="col-sm-4">
					<input id="newPassword" name="newPassword" type="password" value="" maxlength="50" minlength="3" class="${empty user.id?'required':''} form-control"/>
					<c:if test="${empty user.id}"><span class="help-inline"><font color="red">*</font> </span></c:if>
					<c:if test="${not empty user.id}"><span class="help-inline">若不修改密码，请留空。</span></c:if>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">确认密码:</label>
				<div class="col-sm-4">
					<input id="confirmNewPassword" name="confirmNewPassword" type="password" value="" maxlength="50" minlength="3" equalTo="#newPassword" class="form-control"/>
					<c:if test="${empty user.id}"><span class="help-inline"><font color="red">*</font> </span></c:if>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">邮箱:</label>
				<div class="col-sm-4">
					<form:input path="email" htmlEscape="false" maxlength="100" class="email form-control"/>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">电话:</label>
				<div class="col-sm-4">
					<form:input path="phone" htmlEscape="false" maxlength="100" class="form-control"/>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">手机:</label>
				<div class="col-sm-4">
					<form:input path="mobile" htmlEscape="false" maxlength="100" class="form-control"/>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">是否允许登录:</label>
				<div class="col-sm-4">
					<form:select path="loginFlag">
						<form:options items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false"/>
					</form:select>
					<span class="help-inline"><font color="red">*</font> “是”代表此账号允许登录，“否”则不允许登录</span>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label">用户角色:</label>
				<div class="col-sm-4">
					<form:checkboxes path="roleIdList" items="${allRoles}" itemLabel="name" itemValue="id" htmlEscape="false" class="required"/>
					<span class="help-inline"><font color="red">*</font> </span>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			
			<div class="form-group">
				<label class="col-sm-2 control-label" for="remarks">备注:</label>
				<div class="col-sm-4">
					<form:textarea path="remarks" htmlEscape="false" rows="4" maxlength="200" class="form-control"/>
				</div>
			</div>
			<div class="hr-line-dashed"></div>
			<c:if test="${not empty user.id}">
				<div class="form-group">
					<label class="col-sm-2 control-label">创建时间:</label>
					<div class="col-sm-4">
						<label class="lbl"><fmt:formatDate value="${user.createTime}" type="both" dateStyle="full"/></label>
					</div>
				</div>
				<div class="hr-line-dashed"></div>
				<div class="form-group">
					<label class="col-sm-2 control-label">最后登陆:</label>
					<div class="col-sm-4">
						<label class="lbl">IP: ${user.loginIp}&nbsp;&nbsp;&nbsp;&nbsp;时间：<fmt:formatDate value="${user.loginDate}" type="both" dateStyle="full"/></label>
					</div>
				</div>
				<div class="hr-line-dashed"></div>
			</c:if>
			<div class="form-group">
				<label class="col-sm-2 control-label"></label>
				<div class="col-sm-4">
					<shiro:hasPermission name="system:user:edit">
						<input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;
					</shiro:hasPermission>
					<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
				</div>
			</div>
		</form:form>
	</div>
</body>
</html>
